import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/29 16:12
 * @description 思路，每个连续的字符的贡献为 n * (n + 1 ) / 2，n为连续相同字符的个数
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.countHomogenous("abbcccaa");
    }

    public int countHomogenous(String s) {

        int MOD = (int) (1e9 + 7);
        int ans = 0, n = s.length();
        char[] S = s.toCharArray();
        for (int i = 0; i < n; i++) {
            int cnt = 1;
            while (i + 1 < n && S[i] == S[i+1]) {
                i++;
                cnt++;
            }
            long contribute = (long) cnt * (cnt + 1) / 2;
            ans += contribute % MOD;
        }
        return ans;
    }
}
